﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using sdm.exam.domain.Abstract;
using Ninject;

namespace sdm.exam.domain.DataContext
{
    public class ClassRoomDomain
    {
        readonly ISdmExamRepository _repository = Ninjector.Kernel.Get<ISdmExamRepository>();

        public void AddClassRoom(Entities.Classroom classroom)
        {
            _repository.Classrooms.Add(classroom);
            _repository.SaveChanges();
        }

        public List<Entities.Classroom> GetClassRooms()
        {
            var q = from item in _repository.Classrooms select item;
            return q.ToList();
        }

        public void DeleteClassRoom(string classRoomName)
        {
            _repository.Classrooms.Remove(_repository.Classrooms.FirstOrDefault(m=>m.Name==classRoomName));
            _repository.SaveChanges();
        }
    }
}
